<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>demo1</title>
    <style>
        .div1{
            width: 200px;
            height: 200px;
            background-color: red;
            display: flex;
            justify-content: center;
            align-items:center;
            /* 子绝父相 */
            /* position: relative;  */
        }

        .div2{
            width: 100px;
            height: 100px;
            background-color: green;

            /* position: absolute;
            top: 50%;
            left: 50%; */
            /* margin-left: -50px;margin-top: -50px; */
            /* transform: translate(-50%, -50%);  */
        }
    </style>
</head>
<body>
    <div class="div1">
        <div class="div2"></div>
    </div>
</body>
</html>